<?php

class Exam_Form_Admin_Category_Delete extends Engine_Form {
	public function init() {
		$this->setMethod('post')
			->setTitle('Delete Category')
			->setDescription('Are you sure you want to delete it? Delete it will delete all sub-categories, all exam in sub-categories, all exam in this category.');
		
		$categoryId = new Zend_Form_Element_Hidden('category_id');
		$categoryId->addValidator('notEmpty')
			->addValidator('Int')		
			->addValidator(new Zend_Validate_Db_RecordExists(
					Engine_Api::_()->getDbtable('categories', 'exam')->info('name'),
					'category_id'
				)
			);
		$this->addElement($categoryId);
		
		// Buttons
		$this->addElement('Button', 'submit', array (
				'label' => 'Delete Category', 
				'type' => 'submit', 
				'ignore' => true, 
				'decorators' => array (
						'ViewHelper'
				)
		));
		$this->addElement('Cancel', 'cancel', array (
				'label' => 'cancel', 
				'link' => true, 
				'prependText' => ' or ', 
				'onclick' => 'parent.Smoothbox.close();', 
				'decorators' => array (
						'ViewHelper'
				)
		));
		$this->addDisplayGroup(array (
				'submit', 
				'cancel'
		), 'buttons');
		$button_group = $this->getDisplayGroup('buttons');
		$button_group->addDecorator('DivDivDivWrapper');
		
		// Set default action
		$this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
	}	
}